/*
 * Team Fuzzballs
 * Philip Dilse, Keith McKinley, Rebecca Siegel
 */

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class LinkedListTest {

	LinkedList list;
	
	@Before
	public void setUp() throws Exception {
		list = new LinkedList();
	}

	@After
	public void tearDown() throws Exception {
		list = null;
	}

	@Test
	public void testInsert() {
		int first = 1;
		int second = 2;
		int third = 3;
		
		list.insert(first);
		list.insert(second);
		list.insert(third);
		
		// first node should contain 1
		Node n = list.start;
		assertEquals(first, n.getData());
		
		// second node should contain 2
		n = n.getNext();
		assertEquals(second, n.getData());
		
		// third node should contain 3
		n = n.getNext();
		assertEquals(third, n.getData());
		
		// third node next field should be null
		n = n.getNext();
		assertEquals(null, n);
	}
	
	@Test
	public void testDelete() {
		int first = 1;
		int second = 2;
		int third = 3;
		
		list.insert(first);
		list.insert(second);
		list.insert(third);
		
		list.delete(second);
		
		// list should be 1, 3
		Node n = list.start;
		assertEquals(first, n.getData());
		n = n.getNext();
		assertEquals(third, n.getData());
		n = n.getNext();
		assertEquals(null, n);
	}
}
